package com.ynet.middleground.user.model;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ynet.middleground.user.bean.ChannelResourceReq;
import com.ynet.middleground.user.dao.ResourceConfigMapper;
import com.ynet.middleground.user.entity.ChannelConfig;
import com.ynet.middleground.user.entity.ResourceConfig;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资源(接口)信息表 服务实现类
 * </p>
 *
 * @author yangbh
 * @since 2019-10-16
 */
@Component
public class ResourceConfigModel extends ServiceImpl<ResourceConfigMapper, ResourceConfig> {

    public void save(ChannelResourceReq channelResourceReq) {

        // 构建渠道对象
        ResourceConfig resource = new ResourceConfig();

        resource.setInterfaceName(channelResourceReq.getInterfaceName());
        resource.setUrl(channelResourceReq.getUrl());
        resource.setResourceDesc(channelResourceReq.getDesc());
        resource.setStatus(ChannelConfig.STATUS.NORMAL.getCode());
        resource.setCreateBy(channelResourceReq.getOperationUserId());

        // 保存
        this.save(resource);
    }
}
